package com.yale.springbootkaptcha.controller;

import com.google.code.kaptcha.Constants;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * Created by admin on 2017/8/18.
 */
@Controller
public class indexController {

    @RequestMapping(value = {"/index", "/"})
    public String gotoIndex(){
        return "index";
    }

    @RequestMapping(value = "/getCode")
    @ResponseBody
    public String check(HttpServletRequest request){
        HttpSession session = request.getSession();
        String code = (String)session.getAttribute(Constants.KAPTCHA_SESSION_KEY);
        System.out.println("******************验证码是: " + code + "******************");
        return code;
    }


}
